Syllable spacing in Lua#1720
Syllable spacing in Lua#1720davidweichiang wants to merge 23 commits intogregorio-project:developfrom
Conversation
…erently from the old one, in the following ways: + The old algorithm worked by moving the last part of a syllable to the first part of the next syllable. It could therefore break ligatures between the middle and last part of a syllable. The new algorithm works by joining the text boxes together; it does not break ligatures. + If maximumspacewithoutdash > 0, the old algorithm could make the last part of a syllable "jump" across the space between syllables; the new one only rewrites syllables if they are actually touching. - The old algorithm computed syllable spacing after rewriting; the new algorithm computes them in the opposite order. This means that some syllable spacing will be slightly too big or small. This will be fixable when syllable spacing is also moved to Lua.
…calculated in TeX for now, because it's needed in a couple of places, but \GreSyllable only generates a zero-width \hskip, and the Lua code recalculates it and resizes the \hskip accordingly. The Lua syllablefinalskip calculation uses the actual begindifference of the next syllable, not the predicted one (nextbegindifference). In the old code, sometimes this prediction was wrong (gregorio-project#1723). Therefore this commit breaks several tests, but I believe they are all actually bug fixes.
|
Commit 4fa508d starts to move the calculation of Because it uses the actual Because of #1723: Because of #1724: Only miniscule changes: |
- Move syllable clearing for \GreSyllables into Lua, which works by directly measuring the distances between syllables. This fixes issue gregorio-project#1725 but also breaks tests/gabc-output/glyphs/clear.gabc because it now inserts no extra space (and never removes space). - Simplify syllable spacing by directly measuring distances between syllables, similarly to above.
|
Commit ec4e22c moves syllable clearing into Lua. The amount to shift a syllable in order to clear it is now measured exactly, whereas previously it depended on predicting the begindifference of the next syllable, as well as issue #1725. So cleared syllables are tighter than before. Breaks two new tests: |
…en a syllable and the next, a hyphen is inserted. This used to be done in \GreSyllable, but now is done in the Lua pre_linebreak filter. - Added some missing cases to \gre@calculate@eolshift - Remove TeX code computing syllablefinalskip and code that depends on it * It is still used inside the new bar spacing algorithm, but for a different purpose * There is still a macro \gre@calculate@syllablefinalskip, but it actually computes minNotesDistance and minTextDistance - Intra-line and end-of-line hyphens are now generated by the same code * One very minor side effect is that end-of-line hyphens should now be correctly kerned.
|
Commit a48c861 moves hyphenation into Lua. This was the last thing that depended on syllablefinalskip, so syllablefinalskip can be deleted from the TeX code, and perhaps it would make sense to merge (so that @lbssousa can work on #1715), after 6.2.0 of course. Some very minor benefits:
Several more tests are broken. If a hyphenated word comes before a bar, the space between them is now incorrect until bar spacing is moved into Lua. This happens in the following tests:
Miniscule differences:
More than miniscule but not worrisome in my opinion:
|
|
This code defers some computations to the pre-linebreak filter, which can depend on user settings. If the user changes settings in the middle of the score (using |
|
I'd definitely like to see some documentation on the new Lua code before merging. We've been very poor about documenting our Lua code thus far and I'd like to start changing that. I'm thinking that our policy for new Lua code should be as follows: Every new function (or non-trivial change to an existing function) gets a documentation comment in EmmyLua-style: Do you think that's reasonable? The goal is to improve our Lua documentation over time without there being an overwhelming amount of work. (Though if someone gets ambitious and wants to document all current Lua functions, I won't stop them. That's how I really got into the project: creating the TeX documentation.) |
|
The code documentation suggestion seems good. I started a discussion on the gregorio-devel mailing list in an attempt to standardize our lua style. |
|
The last commit takes a first stab at adding the Lua comments. |
|
To fix:
|
- Handle discretionaries (which disrupt syllable numbering) more correctly
rpspringuel
left a comment
There was a problem hiding this comment.
The addition of the Lua comments makes it much easier to read through the new Lua file. Thank you.
Still need CHANGELOG entry. Based on what I saw, I don't think any UPGRADE entry is needed.
| \gre@penalty{-10001}% | ||
| % Above, we emitted kerns of -enddifference and -eolshift early, | ||
| % and they will be emitted again later in \GreSyllable. The | ||
| % second set of kerns has no effect because they are at the |
There was a problem hiding this comment.
If the second set of kerns have no effect because they are at the beginning of a line, can we just not emit them rather than emitting their opposite here to cancel them out?
There was a problem hiding this comment.
There was a problem hiding this comment.
I tried to improve the commenting in this macro. In principle, the enddifference and eolshift kerns should be emitted wherever there is a potential break. Since this syllable has two potential line breaks, it makes sense for it to have two sets of kerns.
|
I believe merging #1743 first will make this one easier, as it will fix a few failing tests. |
|
To fix:
|
…ng/ligaturing after syllable rewriting. This fixes the problem. When two syllables are merged, the link for the first syllable spans both syllables, and the original link for the second syllable is lost.
This is aiming towards #1673, but pursuing a different strategy than what was proposed there.
The first commit (02ec952) moves syllable rewriting into Lua, which has the following benefits:
ETA: These two cases are demonstrated in gregorio-project/gregorio-test#420.
And there are still the following problems:
The first problem can be seen in the test
tex-output/syllable-rewriting/syllable-rewriting.tex
ETA: The existing code was already making an approximation, in that it was aligning the first note and vowel without taking ligaturing and kerning into account. The new code is just extending this approximation to possibly a whole word. In my opinion, the approximation is visible only in the test
syllable-rewriting.tex(because of the unusual font) and causes only a miniscule difference elsewhere.Further tests that have miniscule differences:
gabc-output/glyphs/torculus_resupinus_quilisma.gabc
gabc-output/glyphs/torculus_resupinus.gabc
gabc-output/slurs.gabc
gabc-output/FactusEst.gabc
tex-output/dominican-flats/dominican-flats.tex
tex-output/SalveReginaOP/SalveReginaOP.tex
tex-output/bugs/fix-595/fix-595.tex
tex-output/bugs/fix-1110/fix-1110.tex
tex-output/lyric-centering/lyric-centering.tex
Tests that have big changes:
Closes #1719.